/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package PropertyRental.war.servlets;

import PropertyRental.ejb.persistence.Customer;
import PropertyRental.ejb.persistence.Users;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Bast
 */
class ViewAccountAction extends Action{

    public ViewAccountAction(String success, String fail){
        super(success, fail);
    }
    @Override
    public String perform(HttpServletRequest req) {
        HttpSession session = req.getSession();
        Object account = session.getAttribute("account");
        synchronized(session){
            if (account != null){
                if(account instanceof Users){
                    Users u = (Users)account;
                    if (u instanceof Customer)
                        session.setAttribute("accountType", "Customer");
                    else
                        session.setAttribute("accountType", "Owner");
                    return this.getSuccesspage();
                }
            }
        }
        return this.getFailpage();
    }


}
